package com.cf.r964;

import java.io.*;

public class b {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(System.out);
        in.nextToken(); int t = (int) in.nval;
        while (t-- > 0) {
            in.nextToken(); int a1 = (int) in.nval;
            in.nextToken(); int a2 = (int) in.nval;
            in.nextToken(); int b1 = (int) in.nval;
            in.nextToken(); int b2 = (int) in.nval;
            int ans = 0;
            ans += f(a1, a2, b1, b2);
            ans += f(a1, a2, b2, b1);
            ans += f(a2, a1, b2, b1);
            ans += f(a2, a1, b1, b2);
            out.println(ans);
        }
        out.flush();
        out.close();
        br.close();
    }

    public static int f(int a1, int a2, int b1, int b2) {
        int snt = 0;
        int sve = 0;
        if (a1 > b1) {
            snt++;
        } else if (a1 < b1) {
            sve++;
        }
        if (a2 > b2) {
            snt++;
        } else if (a2 < b2) {
            sve++;
        }
        if (snt > sve) {
            return 1;
        } else {
            return 0;
        }
    }
}
